//package org.example.demo4.config;
//
//import javax.sql.DataSource;
//
//import com.zaxxer.hikari.HikariDataSource;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.mybatis.spring.annotation.MapperScan;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//
//
///**
// * mysql数据源配置
// * @author mk
// * @create 2019年7月29日 下午5:12:10
// */
//@Configuration
//@MapperScan(basePackages = { "org.example.demo4.mapper.freight"},sqlSessionFactoryRef = "db1SqlSessionFactory", sqlSessionTemplateRef = "db1SqlSessionTemplate")
//public class DbFreightConfig {
//
//	private Logger logger = LoggerFactory.getLogger(DbFreightConfig.class);
//
//	@Primary
//	@Bean("primaryDataSourceProperties")
//	@ConfigurationProperties("spring.datasource.one")
//	public DataSourceProperties primaryDataSourceProperties() {
//		return new DataSourceProperties();
//	}
//
//	@Primary
//	@Bean("db1DataSource")
//	@Qualifier(value = "primaryDataSource")
//	@ConfigurationProperties(prefix = "spring.datasource.one.hikari")
//	public HikariDataSource db1DataSource() {
//		return primaryDataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource.class).build();
//	}
//
//
//
//    @Bean
//    @Primary
//    public SqlSessionFactory db1SqlSessionFactory(@Qualifier("db1DataSource") DataSource dataSource) throws Exception {
//    	SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
//        bean.setDataSource(dataSource);
//        bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/**/*.xml"));
//
//        return bean.getObject();
//
//    }
//
//    @Bean
//    @Primary
//    public DataSourceTransactionManager db1TransactionManager(@Qualifier("db1DataSource") DataSource dataSource) {
//        return new DataSourceTransactionManager(dataSource);
//    }
//
//    @Bean
//    @Primary
//    public SqlSessionTemplate db1SqlSessionTemplate(@Qualifier("db1SqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
//        return new SqlSessionTemplate(sqlSessionFactory);
//    }
//
//
//
//}
